package com.rxb.blog.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Author：rxb
 * Date：2020-02-29 20:20
 * Description：<描述>
 */
@Configuration
public class WebMvcConfig   implements WebMvcConfigurer {

    /**
     * 注册拦截器
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //addPathPattern后跟拦截地址，excludePathPatterns后跟排除拦截地址
        registry.addInterceptor(new ConfigInterceptor()).addPathPatterns("/**")
                .excludePathPatterns("/user/login")
                .excludePathPatterns("/user/loginOut")
                .excludePathPatterns("/user/register")
                .excludePathPatterns("/user/sendIdentifyCode")
                .excludePathPatterns("/user/findPassword")//.excludePathPatterns("/login/login");
                .excludePathPatterns("/articleType/getArticleTypesForHome") //首页类型
                .excludePathPatterns(("/article/getArticleListWithType/**"))//首页展示文章列表
                .excludePathPatterns("/article/getMyArticleDetail") //从首页来的 查询 博客详情
                .excludePathPatterns("/comment/getCommentList"); //评论列表
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/images/**").addResourceLocations("file:C:/Users/rxb/Desktop/img/");
    }

}
